package com.zxy.ziems.server.scene.pojo.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.annotation.IEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.zxy.ziems.common.validation.EnumerableValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * @author chdzq
 * @create 2023/3/21
 */
@AllArgsConstructor
@Getter
public enum SceneType implements IEnum<Integer>, EnumerableValue {
    BUILD(1, "楼栋"),
    FLOOR(2, "楼层"),
    OTHER(99, "其他")
    ;

    /**
     * code
     */
    @JsonValue
    @EnumValue
    private Integer code;

    /**
     * name
     */
    private String message;

    @Override
    public Integer getValue() {
        return code;
    }

    @JsonCreator
    public static SceneType getByCode(Integer code) {
        for (SceneType value : SceneType.values()) {
            if (Objects.equals(code, value.getCode())) {
                return value;
            }
        }
        return null;
    }

    @Override
    public Integer getEnumerableValue() {
        return code;
    }

}
